package com.shujia.mr.pinglunWC;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class PingLunReducer extends Reducer<Text, LongWritable,Text, LongWritable> {
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        long sum = 0L;

        for (LongWritable value : values) {
            sum += value.get();
        }

        //将最终的结果写入到文件中
        context.write(key, new LongWritable(sum));
    }
}
